package com.flash.InventoryManagement.mapper;

import com.flash.InventoryManagement.entity.CashAccrualStock;
import com.flash.InventoryManagement.entity.CashStock;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author jr
 * @version 1.0
 * @date 2022/8/23
 */
@Mapper
public interface CashAccrualStockMapper {
    @Select("select count(*) from cashAccrualStock")
    public int countCashAccrualStock();

    @Select("select * from (select rownum rn,c.* from cashAccrualStock c) c" +
            " join cash c2 on c.cashId = c2.cashId "+
            " where 1=1 ${strWhere} and rn between #{page} and #{limit}")

//    "select c.* ,c2.accountName from (select rownum rn,c.* from cashStock c) c "+
//            "join cash c2 on c.cashId = c2.cashId "+
//            "where 1=1 ${strWhere} and rn between #{page} and #{limit}")
    public List<CashAccrualStock> selectCashAccrualStock(Map map);

    @Insert("insert into CashAccrualStock values(#{cashAccrualStockId},#{cashId},#{dateAccrualStock},#{businessType},#{businessState},#{money},#{initialState},#{remark})")
    public int insertCashAccrualStock(CashAccrualStock cashAccrualStock);

    @Update("update cashAccrualStock set cashId=#{cashId},dateAccrualStock=#{dateAccrualStock},businessType=#{businessType},businessState=#{businessState},money=#{money},initialState=#{initialState},remark=#{remark} where cashAccrualStockId=#{cashAccrualStockId}")
    public int updateCashAccrualStock(CashAccrualStock cashAccrualStock);

    @Delete("delete from cashAccrualStock where cashAccrualStockId=#{cashAccrualStockId}")
    public int deleteCashAccrualStock(CashAccrualStock cashAccrualStock);
}
